home *** CD-ROM | disk | FTP | other *** search
/ Family Forum 262 / SOMC Family Forum 262.iso / Xtras / Animation Wizard.dir / 00007_RadioButton.ls < prev    next >
Encoding:
Text File  |  1997-05-10  |  1.5 KB  |  67 lines

  1. property ichCurrent, ichStart, inChannels, iRightAnswer
  2.  
  3. on birth me, startCh, nChannels, rightAnswer, defaultAnswer
  4.   set ichStart to startCh
  5.   set inChannels to nChannels
  6.   repeat with ch = ichStart to ichStart + inChannels - 1
  7.     puppetSprite(ch, 1)
  8.   end repeat
  9.   if voidp(rightAnswer) then
  10.     set iRightAnswer to 0
  11.   else
  12.     set iRightAnswer to rightAnswer
  13.   end if
  14.   if voidp(defaultAnswer) then
  15.     set ichCurrent to 0
  16.   else
  17.     if defaultAnswer = 0 then
  18.       set ichCurrent to 0
  19.     else
  20.       set ichCurrent to ichStart + defaultAnswer - 1
  21.       set the castNum of sprite ichCurrent to the castNum of sprite ichCurrent + 1
  22.       updateStage()
  23.     end if
  24.   end if
  25.   return me
  26. end
  27.  
  28. on mHit me
  29.   set newCh to the clickOn
  30.   if ichCurrent <> 0 then
  31.     if newCh = ichCurrent then
  32.       return 
  33.     end if
  34.     set the castNum of sprite ichCurrent to the castNum of sprite ichCurrent - 1
  35.   end if
  36.   set ichCurrent to newCh
  37.   set the castNum of sprite ichCurrent to the castNum of sprite ichCurrent + 1
  38.   updateStage()
  39. end
  40.  
  41. on mGetChosenAnswer me
  42.   if ichCurrent = 0 then
  43.     return 0
  44.   else
  45.     return ichCurrent - ichStart + 1
  46.   end if
  47. end
  48.  
  49. on mEvaluate me
  50.   if iRightAnswer = 0 then
  51.     alert("Attempting to evaluate, but a correct was not given at initialization")
  52.     return 0
  53.   end if
  54.   set currentAnswer to mGetChosenAnswer(me)
  55.   if currentAnswer = iRightAnswer then
  56.     return 1
  57.   else
  58.     return 0
  59.   end if
  60. end
  61.  
  62. on mCleanUp me
  63.   repeat with ch = ichStart to ichStart + inChannels
  64.     puppetSprite(ch, 0)
  65.   end repeat
  66. end
  67.